<div id="body-wrapper"> <!-- Wrapper for the radial gradient background -->
		<?php getAdminMenu();?>
		
		<div id="main-content"> <!-- Main Content Section with everything -->
			<div class="content-box">
				<div class="content-box-header">
				<h3>搜索</h3>
				<div class="clear"></div>
				</div>
			
				<div class="content-box-content">
					<div class="tab-content default-tab" >
						<form action="<?php echo site_url('/admin/search_agent');?>" onsubmit="return checkSearch();" method="post">
						<fieldset>
						<table>
						<tr>
						<td>代理商用户名：</td><td><input class="text-input large-input" type="text" id="search_agent_name" name="search_agent_name" value="<?php echo $search_name;?>" /></td>
						<td>代理商昵称：</td><td><input class="text-input large-input" type="text" id="search_agent_nickname" name="search_agent_nickname" value="<?php echo $search_nickname;?>" /></td>
						</tr>
						</table>
						<p style="text-align:right;">
							<input class="button"  type="submit" value="搜索" />
						</p>
						</fieldset>
						</form>
					</div>
				</div>
			</div>
			
			<div class="content-box"><!-- Start Content Box -->
				
				<div class="content-box-header">
					
					<h3>订单列表</h3>
					
					<ul class="content-box-tabs">
						<li><a href="#tab1" class="default-tab">列表</a></li> <!-- href must be unique and match the id of target div -->
						<li><a href="#tab2">新增</a></li>
					</ul>
					
					<div class="clear"></div>
					
				</div> <!-- End .content-box-header -->
				
				<div class="content-box-content">
					
					<div class="tab-content default-tab" id="tab1">
						<table>
							<thead>
								<tr>
								   <th><input class="check-all" type="checkbox" /></th>
								   <th>代理商用户名</th>
								   <th>代理商昵称</th>
								   <th>金额</th>
								   <th>状态</th>
								   <th>创建时间</th>
								   <th>操作</th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td colspan="10">
										<div class="bulk-actions align-left">
											<select name="bat_edit_agent" id="bat_edit_agent">
												<option value="nosubmit">请选择</option>
												<option value="0">启用</option>
												<option value="-1">禁用</option>
											</select>
											<a class="button" href="javascript:void(0)" onclick="bat_edit_agent()">确定</a>
										</div>
										<?php echo $pages;?> <!-- End .pagination -->
										<div class="clear"></div>
									</td>
								</tr>
							</tfoot>
						 
							<tbody>
							<?php if ($lists && $lists->num_rows() > 0):?>
							<?php foreach ($lists->result() as $list):?>
								<tr>
									<td><input type="checkbox" name="agent_id" value="<?php echo $list->id;?>" /></td>
									<td><?php echo $list->name;?></td>
									<td><?php echo $list->nickname;?></td>
									<td>￥ <?php echo $list->amount?></td>
									<td><?php echo getAgentStatus($list->status);?></td>
									<td><?php echo $list->create_time;?></td>
									<td>
										<!-- Icons -->
										<a href="<?php echo site_url('/admin/delete/'.$list->id);?>" title="Delete"><img src="/img/icons/cross.png" alt="Delete" /></a>
										 <?php if($list->status ==0){?>
										 <a href="<?php echo site_url('/admin/edit_agent_disable/'.$list->id);?>" title="禁用代理商">禁用</a>
										 <?php }?>
										 <?php if($list->status ==-1){?>
										 <a href="<?php echo site_url('/admin/edit_agent_abled/'.$list->id);?>" title="启用代理商">启用</a>
										 <?php }?>
										 <a href="<?php echo site_url('/admin/edit_agent/'.$list->id);?>" title="修改代理商信息">修改</a>
									</td>
								</tr>
							<?php endforeach;?>
							<?php endif;?>	
							</tbody>
							
						</table>
						
					</div> <!-- End #tab1 -->
					
					<div class="tab-content" id="tab2">
						<form action="<?php echo site_url('/admin/agentDoAdd');?>" onsubmit="return check();" method="post">
							<fieldset>
							<table>
								<tr>
									<td>创建时间：</td>
									<td  align="left"><input class="text-input large-input" type="text" id="create_time" name="create_time" value="<?php echo date('Y-m-d H:i:s');?>" /> </td>
								</tr>
								<tr>
									<td>代理商用户名：</td>
									<td  align="left"><input class="text-input large-input" type="text" id="agent_name" name="agent_name" value="" /> </td>
								</tr>
								<tr>
									<td>代理商密码：</td>
									<td  align="left"><input class="text-input large-input" type="password" id="newpasswd" name="newpasswd" value="" /> </td>
								</tr>
								<tr>
									<td>确认密码：</td>
									<td  align="left"><input class="text-input large-input" type="password" id="cfmpasswd" name="cfmpasswd" value="" /> </td>
								</tr>
								<tr>
									<td>金额：</td>
									<td  align="left"><input class="text-input large-input" type="text" id="agent_amount" name="agent_amount" value="" /> </td>
								</tr>
								<tr>
									<td>代理商昵称：</td>
									<td  align="left"><input class="text-input large-input" type="text" id="agent_nickname" name="agent_nickname" value="" /> </td>
								</tr>
								<tr>
									<td>状态：</td>
									<td  align="left">
										<select id="agent_status" name="agent_status">
											<option value="0">正常</option>
											<option value="-1">禁用</option>
										</select>
									</td>
								</tr>
							</table>
								<p style="text-align:right;">
									<input class="button"  type="submit" value="提 交 报 备" />
								</p>
							</fieldset>
							<div class="clear"></div><!-- End .clear -->
						</form>
					</div> <!-- End #tab2 -->        
				</div> <!-- End .content-box-content -->
			</div> <!-- End .content-box -->
			<div id="footer">
				<small> <!-- Remove this notice or replace it with whatever you want -->
						&#169; Powered by <a href="#">Leslee</a> | <a href="#">Top</a>
				</small>
			</div><!-- End #footer -->
		</div> <!-- End #main-content -->
	</div>
	<script>
	function check()
 	{
 		var newpwd = $.trim($("#newpasswd").val());
 		var agent_name	= $.trim($("#agent_name").val());
 		var agent_nickname	= $.trim($("#agent_nickname").val());
 		var cfmpwd = $.trim($("#cfmpasswd").val());
		if (newpwd == '' || newpwd != cfmpwd)
		{
			alert("请输入新密码和确认密码！");
			return false;
		}
		if(agent_name=='')
		{
			alert('代理商用户名不能为空');
			return false;
		}
		if(agent_nickname=='')
		{
			alert('代理商昵称不能为空');
			return false;
		}
		return true;
 	}
 	function checkSearch()
 	{
 		if (!$("#search_agent_name").val() && !$("#search_agent_nickname").val())
 		{
 			alert("请输入搜索关键字");
 			return false;
 		}
 		return true;
 	}
	function bat_edit_agent()
 	{
 	 	var ids	= '';
 	 	if($('[name=agent_id]:checked').size()>0)
 	 	{
 	 		$('[name=agent_id]:checked').each(function()
 	 	 	{
 	 	 	 	ids	+=$(this).val()+"-";
 	 	 	})
 	 	}
 	 	else
 	 	{
 	 	 	alert('请选择订单');
 	 	 	return false;
 	 	}
		if($("#bat_edit_agent").val()!='nosubmit')
		{
			window.location.href="/admin/bat_edit_agent/"+$("#bat_edit_agent").val()+'/'+ids;
		}
		else
		{
			alert('请选择状态');
		}
 	}
	</script>